
package at.fhj.ase.clientarch.common.util;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;

public final class WindowUtil {
	
  /** Centers the provided {@link Window} instance on your screen (not <code>null</code>) using {@link Window#setLocation(int, int)} */
  public static Window centerWindow(Window windowToBeCentered) {
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    final int newWidth = (int) ((screenSize.getWidth() - windowToBeCentered.getWidth()) / 2);
    final int newHeight = (int) ((screenSize.getHeight() - windowToBeCentered.getHeight()) / 2);

    windowToBeCentered.setLocation(newWidth, newHeight);
    return windowToBeCentered;
  }
  
  private WindowUtil() {
	  throw new AssertionError("WindowUtil: Util classes are not intended/allowed to be instantiated!");
  }

}
